package lec10.am;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class AAddB extends JFrame implements ActionListener{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	JTextField ta;
	JTextField tb;
	JTextField tc;
	JButton eq;
	
	public  AAddB() {
		super("My Calc 0.1a");
		setLayout(new FlowLayout());
		this.add(ta=new JTextField(10));
		this.add(new JLabel("+"));
		this.add(tb=new JTextField(10));
		this.add(eq=new JButton("="));
		this.add(tc=new JTextField(10));
		this.setSize(450,80);
		this.setVisible(true);
		eq.addActionListener(this);

	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==eq)
		{
			int ia=Integer.parseInt(ta.getText());
			int ib=Integer.parseInt(tb.getText());
			
			int ic=ia+ib;
			
			tc.setText(Integer.toString(ic));
		}
	}
	
	public static void main(String[] args) {
		new AAddB();
	}
	

}
